package com.edu.base.ums.countrycode.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.base.ums.countrycode.domain.ClsMemberCountrycode;
import com.edu.base.ums.countrycode.service.IClsMemberCountrycodeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 国家代号(CountryCode)与区号Controller
 * 
 * @author lzs
 * @date 2021-06-24
 */
@RestController
@RequestMapping("/cls/countrycode")
public class ClsMemberCountrycodeController extends BaseController
{
    @Autowired
    private IClsMemberCountrycodeService clsMemberCountrycodeService;

    /**
     * 查询国家代号(CountryCode)与区号列表
     */
    @PreAuthorize("@ss.hasPermi('cls:countrycode:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClsMemberCountrycode clsMemberCountrycode)
    {
        startPage();
        List<ClsMemberCountrycode> list = clsMemberCountrycodeService.selectClsMemberCountrycodeList(clsMemberCountrycode);
        return getDataTable(list);
    }

    /**
     * 导出国家代号(CountryCode)与区号列表
     */
    @PreAuthorize("@ss.hasPermi('cls:countrycode:export')")
    @Log(title = "国家代号(CountryCode)与区号", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ClsMemberCountrycode clsMemberCountrycode)
    {
        List<ClsMemberCountrycode> list = clsMemberCountrycodeService.selectClsMemberCountrycodeList(clsMemberCountrycode);
        ExcelUtil<ClsMemberCountrycode> util = new ExcelUtil<ClsMemberCountrycode>(ClsMemberCountrycode.class);
        return util.exportExcel(list, "countrycode");
    }

    /**
     * 获取国家代号(CountryCode)与区号详细信息
     */
    @PreAuthorize("@ss.hasPermi('cls:countrycode:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(clsMemberCountrycodeService.selectClsMemberCountrycodeById(id));
    }

    /**
     * 新增国家代号(CountryCode)与区号
     */
    @PreAuthorize("@ss.hasPermi('cls:countrycode:add')")
    @Log(title = "国家代号(CountryCode)与区号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClsMemberCountrycode clsMemberCountrycode)
    {
        return toAjax(clsMemberCountrycodeService.insertClsMemberCountrycode(clsMemberCountrycode));
    }

    /**
     * 修改国家代号(CountryCode)与区号
     */
    @PreAuthorize("@ss.hasPermi('cls:countrycode:edit')")
    @Log(title = "国家代号(CountryCode)与区号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClsMemberCountrycode clsMemberCountrycode)
    {
        return toAjax(clsMemberCountrycodeService.updateClsMemberCountrycode(clsMemberCountrycode));
    }

    /**
     * 删除国家代号(CountryCode)与区号
     */
    @PreAuthorize("@ss.hasPermi('cls:countrycode:remove')")
    @Log(title = "国家代号(CountryCode)与区号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(clsMemberCountrycodeService.deleteClsMemberCountrycodeByIds(ids));
    }
}
